home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 24.0 KB | 868 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: TblFrame.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Table.hpp"
-
- // ----- TablePart Includes -----
-
- #ifndef TBLFRAME_H
- #include "TblFrame.h"
- #endif
-
- #ifndef TBLPART_H
- #include "TblPart.h"
- #endif
-
- #ifndef TBLPROXY_H
- #include "TblProxy.h"
- #endif
-
- #ifndef TBLSEL_H
- #include "TblSel.h"
- #endif
-
- #ifndef TBLTRCKR_H
- #include "TblTrckr.h"
- #endif
-
- #ifndef TBLCMDS_H
- #include "TblCmds.h"
- #endif
-
- #ifndef TBLLINK_H
- #include "TblLink.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWEDCMD_H
- #include "FWEdCmd.h"
- #endif
-
- #ifndef FWPROXY_H
- #include "FWProxy.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWFCTCLP_H
- #include "FWFctClp.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- // ----- Macintosh Toolbox Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__RESOURCES__)
- #include <Resources.h>
- #endif
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- // ----- [HLX] need to move these somewhere -----
- const char kLeftArrow = 0x1C;
- const char kRightArrow = 0x1D;
- const char kUpArrow = 0x1E;
- const char kDownArrow = 0x1F;
- const char kDelKey = 0x08;
- const char kFwdDelKey = 0x7f;
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfTable
- #endif
-
- //========================================================================================
- // class CTableFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CTableFrame
- //----------------------------------------------------------------------------------------
-
- CTableFrame::CTableFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CTablePart* tablePart) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, tablePart),
- fTablePart(NULL),
- fGridShown(TRUE),
- fSelectFrame(FW_kZeroRect, FW_kFrame, FW_PInk(FW_kXOr), FW_PStyle(FW_IntToFixed(2)))
- {
- SetDroppable(ev, fGridShown);
-
- fTablePart = tablePart;
- fDraggedCell.fX = fDraggedCell.fY = -1;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::~CTableFrame
- //----------------------------------------------------------------------------------------
-
- CTableFrame::~CTableFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::GetSelection
- //----------------------------------------------------------------------------------------
-
- CTableSelection* CTableFrame::GetSelection(Environment* ev) const
- {
- return (CTableSelection*)GetPresentation(ev)->GetSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean result = TRUE;
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
-
- switch(commandID)
- {
- case cHideShowGrid:
- HideShowGrid(ev);
- break;
-
- default:
- result = FALSE;
- break;
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::HideShowGrid
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::HideShowGrid(Environment* ev)
- {
- fGridShown = !fGridShown;
- SetDroppable(ev, fGridShown);
-
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- FW_CFacetIterator ite2(ev, facet, kODChildrenOnly, kODFrontToBack);
- for (ODFacet* embeddedFacet = ite2.First(ev); ite2.IsNotComplete(ev); embeddedFacet = ite2.Next(ev))
- {
- embeddedFacet->SetSelected(ev, fGridShown);
- }
-
- FW_CFacetContext fc(ev, facet);
-
- if (IsActive(ev))
- DrawSelectBorder(ev, fc, GetSelection(ev)->GetCell());
-
- DrawGrid(ev, fc, fGridShown);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CFacetContext fc(ev, odFacet, invalidShape);
-
- FW_CRect invalidRect;
- fc.GetClipRect(invalidRect);
-
- // Erase invalid portion of the frame
- FW_CRectShape::RenderRect(fc, invalidRect, FW_kFill, FW_kWhiteEraseInk);
-
- // Draw the table grid
- if (fGridShown)
- DrawGrid(ev, fc, TRUE);
-
- // Draw the selection
- if (IsActive(ev) && fGridShown)
- DrawSelectBorder(ev, fc, GetSelection(ev)->GetCell());
-
- //--- Draw Link borders ---
- FW_CAcquiredODWindow aqODWindow = odFacet->GetFrame(ev)->AcquireWindow(ev);
- if (aqODWindow->ShouldShowLinks(ev))
- {
- //--- Draw borders around link sources ---
- FW_CPartPublishIterator siter(fTablePart);
- for (CTablePublishLink* slink = (CTablePublishLink*)siter.First(); siter.IsNotComplete();
- slink = (CTablePublishLink*)siter.Next())
- {
- DrawLinkBorder(ev, slink->GetCell(ev), fc, TRUE);
- }
-
- //--- Draw borders around link destinations ---
- FW_CPartSubscribeIterator iter(fTablePart);
- for (CTableSubscribeLink* link = (CTableSubscribeLink*)iter.First(); iter.IsNotComplete();
- link = (CTableSubscribeLink*)iter.Next())
- {
- DrawLinkBorder(ev, link->GetCell(ev), fc, FALSE);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DrawSelectBorder
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::DrawSelectBorder(Environment* ev, FW_CFacetContext& fc, const CCell& cell)
- {
- FW_CRect rect;
- fTablePart->FindRect(cell, rect);
- rect.Inset(FW_IntToFixed(-1), FW_IntToFixed(-1));
-
- fSelectFrame.SetGeometry(rect);
- fSelectFrame.Render(fc);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::DrawGrid
- //---------------------------------------------------------------------------------------
-
- void CTableFrame::DrawGrid(Environment* ev, FW_CGraphicContext& gc, FW_Boolean gray)
- {
- // Get the frame's rect at (0,0), inset by margins
- FW_CRect rect;
- this->GetRect(ev, rect);
-
- // Draw the table grid
- FW_CLineShape lineShape;
- lineShape.GetStyle()->SetPattern(gray ? FW_kGrayPat : FW_kWhitePat);
-
- FW_CFixed xy;
- short rc;
- for(xy = rect.top, rc = 0; xy < rect.bottom; xy += fTablePart->GetHeight(rc++) + kBorderHeight)
- {
- lineShape.SetLineStart(rect.left, xy);
- lineShape.SetLineEnd(rect.right, xy);
- lineShape.Render(gc);
- }
-
- for(xy = rect.left, rc = 0; xy < rect.right; xy += fTablePart->GetWidth(rc++) + kBorderHeight)
- {
- lineShape.SetLineStart(xy, rect.top);
- lineShape.SetLineEnd(xy, rect.bottom);
- lineShape.Render(gc);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::DoAdjustMenus
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- FW_Boolean hasSelection = !GetSelection(ev)->IsEmpty(ev);
-
- menuBar->EnableAndToggleCommand(ev, cHideShowGrid, TRUE, fGridShown);
-
- // If an embedded part is selected, change Copy item to "Copy Part"
- menuBar->SetItemString(ev, kODCommandCopy, hasSelection ? FW_CString32("Copy Part") : FW_CString32("Copy"));
-
- menuBar->EnableCommand(ev, kODCommandCopy, fGridShown && hasSelection);
- menuBar->EnableCommand(ev, kODCommandClear, fGridShown && hasSelection);
- menuBar->EnableCommand(ev, kODCommandCut, fGridShown && hasSelection);
-
- menuBar->EnableCommand(ev, kODCommandInsert, fGridShown);
-
- // Check clipboard for paste
- menuBar->EnableCommand(ev, kODCommandPaste, fGridShown && HasPropertyOnClipboard(ev, kODPropContentFrame, NULL));
-
- menuBar->EnableCommand(ev, kODCommandPasteAs, fGridShown && HasPropertyOnClipboard(ev, kODPropLinkSpec, kODLinkSpec));
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CEmbeddingFrame::FrameShapeChanged(ev);
-
- // ----- Recalculate the clip of all my embedded facets -----
- FW_CFacetClipper facetClipper(ev, fTablePart);
- facetClipper.Clip(ev, GetPresentation(ev), NULL);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoCharKey
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent)
- {
- FW_Boolean tWasHandled = FALSE;
- CCell cell = this->GetSelection(ev)->GetCell();
- CCell size = fTablePart->GetSize();
-
- switch (theCharKeyEvent.GetChar(ev))
- {
- case kLeftArrow:
- if(cell.fX > 0)
- {
- cell.fX -= 1;
- this->SelectCell(ev, cell, TRUE);
- tWasHandled = TRUE;
- }
- break;
- case kRightArrow:
- if(cell.fX < size.fX - 1)
- {
- cell.fX += 1;
- this->SelectCell(ev, cell, TRUE);
- tWasHandled = TRUE;
- }
- break;
- case kUpArrow:
- if(cell.fY > 0)
- {
- cell.fY -= 1;
- this->SelectCell(ev, cell, TRUE);
- tWasHandled = TRUE;
- }
- break;
- case kDownArrow:
- if(cell.fY < size.fY - 1)
- {
- cell.fY += 1;
- this->SelectCell(ev, cell, TRUE);
- tWasHandled = TRUE;
- }
- break;
-
- case kDelKey:
- case kFwdDelKey:
- if(this == GetPart()->GetActiveFrame(ev))
- {
- FW_CEditCommand* cmd = this->NewEditCommand(ev, kODCommandClear);
- if (cmd)
- GetPart()->ExecuteCommand(ev, cmd);
- tWasHandled = TRUE;
- }
- break;
- }
-
- return tWasHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- if (!fGridShown)
- return TRUE;
-
- if (GetSelection(ev)->IsMouseInDraggableItem(ev, this, theMouseEvent, FALSE))
- {
- Drag(ev, theMouseEvent);
- }
- else
- {
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
-
- CCell cell;
- ETableLoc tl = fTablePart->HitTest(ev, this, where, cell);
-
- if (tl != kTLNone && tl != kTLCell)
- this->Resize(ev, theMouseEvent, cell, tl);
- }
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::DoMouseDownInEmbeddedFrameBorder
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::DoMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent)
- {
- if (fGridShown)
- this->Drag(ev, theBorderMouseEvent);
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::SelectCell
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::SelectCell(Environment* ev, const CCell& cell, FW_Boolean drawNow)
- {
- GetSelection(ev)->Select(ev, cell, drawNow);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Resize
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::Resize(Environment* ev,
- const FW_CMouseEvent& theMouseEvent,
- const CCell& cell,
- ETableLoc tl)
- {
- FW_ASSERT(tl != kTLNone && tl != kTLCell);
- FW_Boolean result = FALSE;
-
- // maximum rectangle
- FW_CRect maxRect;
- this->GetRect(ev, maxRect);
- maxRect.right -= kPenWidth;
- maxRect.bottom -= kPenHeight;
-
- // Location of borders
- FW_CRect cellRect;
- fTablePart->FindRect(cell, cellRect);
-
- FW_CPoint borders;
- if ((tl & kTLLeftBorder) != 0)
- {
- maxRect.left = ((cell.fX == 0) ? cellRect.left : fTablePart->FindLeft(cell.fX - 1)) + kBorderWidth;
- borders.x = cellRect.left;
- }
- else
- {
- maxRect.left = cellRect.left + kBorderWidth;
- borders.x = cellRect.right;
- }
-
- if ((tl & kTLTopBorder) != 0)
- {
- maxRect.top = ((cell.fY == 0) ? cellRect.top : fTablePart->FindTop(cell.fY - 1)) + kBorderHeight;
- borders.y = cellRect.top;
- }
- else
- {
- maxRect.top = cellRect.top + kBorderHeight;
- borders.y = cellRect.bottom;
- }
-
-
- // Create a tracker for the grid lines
- CGridLineTracker tracker(ev, this, theMouseEvent.GetFacet(ev), tl, maxRect, borders);
-
- if (tracker.Track(ev, theMouseEvent))
- {
- // Set the new cell size
- FW_CPoint delta = tracker.GetNewBorders() - tracker.GetOldBorders();
- if (delta.x || delta.y)
- {
- fTablePart->Resize(ev, cell, tl, delta);
- result = TRUE;
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::Drag
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::Drag(Environment* ev, const FW_CMouseEvent& event)
- {
- fDraggedCell = GetSelection(ev)->GetCell();
-
- FW_Boolean result = FW_CEmbeddingFrame::Drag(ev, event);
-
- fDraggedCell.fX = fDraggedCell.fY = -1;
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::FocusStateChanged
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::FocusStateChanged(Environment* ev, ODTypeToken focus, FW_Boolean newState, ODFrame* newOwner)
- {
- FW_CEmbeddingFrame::FocusStateChanged(ev, focus, newState, newOwner);
-
- if (focus == FW_CPart::gSelectionFocusToken)
- {
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- if (fGridShown)
- {
- FW_CFacetContext fc(ev, facet);
- DrawSelectBorder(ev, fc, GetSelection(ev)->GetCell());
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTableFrame::AdjustCursor(Environment* ev, ODFacet* odFacet, const FW_CPoint& where)
- {
- FW_Boolean cursorAdjusted = FALSE;
-
- // I don't want the Open Hand Cursor if I have the grid hidden because I am not supposed to
- // be able to move anything
- if (fGridShown)
- cursorAdjusted = FW_CEmbeddingFrame::AdjustCursor(ev, odFacet, where);
-
- if (!cursorAdjusted && fGridShown)
- {
- CCell cell;
- ETableLoc tl = fTablePart->HitTest(ev, this, where, cell);
-
- cursorAdjusted = TRUE;
-
- if (tl == kTLCell || tl == kTLNone)
- FW_gArrowCursor.Select();
- else if (tl == kTLLeftBorder || tl == kTLRightBorder)
- FW_gSizeWECursor.Select();
- else if (tl == kTLTopBorder || tl == kTLBottomBorder)
- FW_gSizeNSCursor.Select();
- else
- FW_gSizeNWSECursor.Select();
- }
-
- return cursorAdjusted;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::GetRect
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::GetRect(Environment* ev, FW_CRect& rect) const
- {
- rect = GetBounds(ev);
- rect.left += kHMargin;
- rect.top += kVMargin;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CTableFrame::NewDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint)
- {
- FW_ASSERT(frame == this);
-
- CCell dropCell;
- fTablePart->HitTest(ev, this, dropPoint, dropCell);
-
- if (dropCell == fDraggedCell)
- return NULL;
- else
- return FW_NEW(CCellDropCommand, (ev, fTablePart, this,
- dropInfo, odFacet, dropPoint,
- dropCell, fDraggedCell));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDropTracker
- //----------------------------------------------------------------------------------------
-
- FW_CDropTracker* CTableFrame::NewDropTracker(Environment *ev, FW_CView* view, ODFacet* facet)
- {
- return FW_NEW(CTableDropTracker, (ev, fTablePart, this, facet, fDraggedCell));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::CreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- ODFacet* CTableFrame::CreateEmbeddedFacet(Environment* ev,
- ODFacet* embeddingFacet,
- FW_MProxy* proxy,
- ODFrame* embeddedFrame,
- ODShape* proposedClipShape)
- {
- CCell cell = ((CTableProxy*)proxy)->GetCell();
-
- FW_CRect rect;
- fTablePart->FindRect(cell, rect);
-
- FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, rect.TopLeft());
-
- return embeddingFacet->CreateEmbeddedFacet(ev,
- embeddedFrame,
- proposedClipShape,
- aqExternalTransform,
- NULL, // Canvas
- NULL, // biasCanvas
- NULL, // siblingFacet
- kODFrameInFront);
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::EmbedSingleFrame
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::EmbedSingleFrame(Environment* ev,
- ODPart* odEmbeddedPart,
- ODFrame* odEmbeddedFrame, // might be null
- ODShape* frameShape)
- {
- FW_UNUSED(frameShape);
-
- CCell selectionCell = GetSelection(ev)->GetCell();
-
- CTableProxy* proxy = fTablePart->CellToProxy(ev, selectionCell);
- if (proxy)
- proxy->DetachEmbeddedFrames(ev);
-
- FW_CRect rect;
- fTablePart->FindRect(selectionCell, rect);
- rect.Place(FW_kZeroPoint);
-
- FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, rect);
-
- // ----- Create the proxy -----
- CTableProxy* newProxy = new CTableProxy(ev, fTablePart, GetPresentation(ev));
- newProxy->SetCell(selectionCell);
-
- // ----- Add the newProxy to the part -----
- fTablePart->AddProxy(newProxy);
-
- // ----- Embed the part or the frame -----
- GetPresentation(ev)->Embed(ev,
- odEmbeddedPart,
- odEmbeddedFrame,
- newProxy,
- aqShape,
- fTablePart->GetSession(ev)->Tokenize(ev, kODViewAsFrame),
- fTablePart->GetSession(ev)->Tokenize(ev, kODPresDefault),
- 0, // groupe id
- FALSE); // sub frame
-
- GetSelection(ev)->InvalidateSelection(ev);
-
- // ----- Delete the old proxy if there was one there
- if (proxy != NULL)
- {
- fTablePart->RemoveProxy(proxy);
- delete proxy;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewEditCommand
- //----------------------------------------------------------------------------------------
-
- FW_CEditCommand* CTableFrame::NewEditCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(CTableEditCommand, (ev,
- commandID,
- fTablePart,
- this,
- this->GetSelection(ev)));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::NewDragCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDragCommand* CTableFrame::NewDragCommand(Environment *ev, FW_CFrame* theFrame)
- {
- return FW_NEW(CCellDragCommand, (ev, fTablePart, theFrame, this->GetSelection(ev)));
- }
-
- //----------------------------------------------------------------------------------------
- // CTableFrame::MoveProxy
- //----------------------------------------------------------------------------------------
-
- void CTableFrame::MoveProxy(Environment* ev, CTableProxy* proxy, const CCell& destCell)
- {
- // Invalidate the source cell
- FW_CRect rect;
- CCell srcCell = proxy->GetCell();
- fTablePart->FindRect(srcCell, rect);
- this->GetPresentation(ev)->Invalidate(ev, rect);
-
- proxy->MoveEmbeddedFrames(ev, destCell);
- proxy->SetCell(destCell);
- this->SelectCell(ev, destCell, FALSE);
-
- // Invalidate the destination cell
- fTablePart->FindRect(destCell, rect);
- this->GetPresentation(ev)->Invalidate(ev, rect);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::DrawLinkBorder
- //---------------------------------------------------------------------------------------
-
- void CTableFrame::DrawLinkBorder(Environment* ev,
- const CCell& cell,
- FW_CFacetContext& fc,
- FW_Boolean isSourceLink)
- {
- FW_CRect rect;
- fTablePart->FindRect(cell, rect);
- FW_CRectShape rectShape(rect, FW_kFrame);
- if (isSourceLink)
- {
- rectShape.GetUnSharedStyle()->SetPattern(FW_kLightGrayPat);
- rectShape.GetUnSharedInk()->SetTransferMode(FW_kOr);
- }
- else
- {
- rectShape.GetUnSharedStyle()->SetPattern(FW_kAntPat);
- rectShape.GetUnSharedInk()->SetTransferMode(FW_kXOr);
- }
- rectShape.GetUnSharedStyle()->SetPenSize(FW_IntToFixed(3));
- rectShape.Inset(FW_IntToFixed(1), FW_IntToFixed(1));
- rectShape.Render(fc);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::FacetAdded
- //---------------------------------------------------------------------------------------
- void CTableFrame::FacetAdded(Environment* ev, ODFacet* facet)
- {
- FW_CEmbeddingFrame::FacetAdded(ev, facet); // call inherited
-
- // We need to register any link destinations that were just internalized.
- fTablePart->RegisterSubscribers(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::ShowPartInfo
- //---------------------------------------------------------------------------------------
- void CTableFrame::ShowPartInfo(Environment* ev)
- {
- if (fTablePart->ShowLinkInfo(ev, this)) return;
-
- // Table part didn't handle it, so call inherited
- FW_CEmbeddingFrame::ShowPartInfo(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // CTableFrame::RevealFrame
- //---------------------------------------------------------------------------------------
- FW_Boolean CTableFrame::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- FW_UNUSED(revealShape);
-
- // Change table selection to the cell of the embedded frame
- CTableProxy* proxy = (CTableProxy*) this->GetProxy(ev, embeddedFrame);
- if (proxy)
- {
- this->SelectCell(ev, proxy->GetCell(), TRUE);
- return TRUE;
- }
-
- return FALSE;
- }
-